<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>协作申请-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">协作申请</div>
		<div class="right">
			<a href="__APP__/Index/assist_apply_add" class="btn left ml5">添加协作申请表</a>
		</div>
	</div>
	<div id="content">
		<!--div class="filter">
			<div class="filter-item">
				<div class="filter-title">所属中心：</div>
				<ul class="filter-order">
					<li <if condition="$center_id eq -10">class="current"</if>>
						<a href="__APP__/Index/meeting_minutes/center_id/-10">全部</a>
					</li>
					<foreach name="center_type" item="vo">
					<li <if condition="$center_id eq $vo['id']">class="current"</if>>
						<a href="__APP__/Index/meeting_minutes/center_id/{$vo['id']}">{$vo['first_name']}</a>
					</li>
					</foreach>
				</ul>
			</div>
		</div-->
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="">协作申请编号</td>
					<td width="">项目编号</td>
					<td width="">项目经理/项目负责人</td>
					<td width="">协作工作性质</td>
					<td width="">需求部门</td>
					<td width="">申请人(日期)</td>
					<td width="">状态</td>
					<td width="50">管理</td>
				</tr>
				<if condition="$result eq NULL">
				<tr>
					<td colspan="8" class="text-center">暂无相关内容</td>
				</tr>
				</if>
				<foreach name="result" item="vo">
				<tr>
					<td><a href="__APP__/Index/assist_apply_detail/id/{$vo['id']}/no/no">{$vo['order_number']}</a></td>
					<td><span title="{$vo['project_name']}" data-placement="right" data-toggle="tooltip">{$vo['project_num']}</span></td>
					<td>{$vo['manager_name']}</td>
					<td>{$vo['work_nature']}</td>
					<td>{$vo['demand_depart']}</td>
					<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
					<td>
						<if condition="$vo['status'] eq -1">未提交<if condition="$vo['dh_uid'] neq NULL"><span title="{$vo['dh_user']}({$vo['dh_date']|substr=0,10}):{$vo['dh_message']}" data-placement="right" data-toggle="tooltip" class="red">(已打回)<span></if>
						<elseif condition="$vo['status'] eq 1"/>待【项目负责人】审核
						<elseif condition="$vo['status'] eq 2"/>待【营销部负责人】审批
						<elseif condition="$vo['status'] eq 3"/>进行中
						<elseif condition="$vo['status'] eq 4"/>已完结
						</if>
					</td>
					<td class="nowrap">
						<if condition="$vo['status'] eq -1">
							<if condition="$vo['dh_message'] neq '' and $vo['arrive_status'] eq -1">
								<a href="javascript:;" mid="{$vo['id']}" uuid="{$login_id}" data-toggle="tooltip" data-placement="left" title="重新提交" class="btn-rest-submit mr5"><i class="glyphicon glyphicon-ok"></i></a>
							<else/>
								<a href="javascript:;" mid="{$vo['id']}" uuid="{$login_id}" data-toggle="tooltip" data-placement="left" title="提交" class="audit mr5"><i class="glyphicon glyphicon-ok"></i></a>
							</if>
							<a href="__APP__/Index/assist_apply_edit/id/{$vo['id']}" data-toggle="tooltip" data-placement="left" title="编辑" class="mr5"><i class="glyphicon glyphicon-edit"></i></a>
							<a href="javascript:;" mid="{$vo['id']}" action="delete" data-toggle="tooltip" data-placement="left" title="删除" class="delete"><i class="glyphicon glyphicon-trash"></i></a>
						<elseif condition="$vo['status'] eq 1"/>
							<a href="javascript:;" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="放弃提交" class="remove"><i class="glyphicon glyphicon-remove"></i></a>
						<elseif condition="$vo['status'] eq 3"/>
							<a href="javascript:;" mid="{$vo['id']}" status="{$vo['status']}" data-toggle="tooltip" data-placement="left" title="完成确认" class="true mr5"><i class="glyphicon glyphicon-ok"></i></a>
						</if>
					</td>
				</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--弹出框-->
<div class="modal fade" id="customeModal">
	<div class="modal-dialog w800">
		<div class="modal-content">
			<div class="modal-header">
				<h4>完成确认</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="side_td" width="12%"><span class="asterisk">*</span>确认内容</td>
						<td width="88%"><textarea name="confirm" class="form-control w600 h150" autocomplete="off"></textarea><input name="confirm_hid" type="hidden"><span class="error-item">必填项</span></td>
					</tr>
					<tr>
						<td class="side_td" width="12%">改进建议</td>
						<td width="88%"><textarea name="confirm_proposal" class="form-control w600 h150" autocomplete="off"></textarea><input name="confirm_proposal_hid" type="hidden"></td>
					</tr>
					<tr>
						<td class="side_td" width="12%"><span class="asterisk">*</span>总体评价</td>
						<td>
							<label class="radio-inline"><input type="radio" name="confirm_evaluate" value="优" autocomplete="off">优</label>
							<label class="radio-inline"><input type="radio" name="confirm_evaluate" value="良" autocomplete="off">良</label>
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--重新提交框-->
<div class="modal fade" id="myModal_submit">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>重新提交</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>原因</strong></td>
						<td>
							<textarea name="remark" placeholder="重新提交理由" class="form-control w300 submit_info left" autocomplete="off"></textarea>
							<span class="error-item left">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$("textarea").each(function(){
		var textss = $(this).text(),
			reg2 = new RegExp("<br/>", "g"),
			str = textss.replace(reg2, "\n");
		$(this).html(str);
	})
	//删除
	$(".delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Index/assist_apply_ajax","data":{"id":"mid","action":"action"}});
	$('.audit').on("click",function(){
		var status = 1,
			uuid = $(this).attr("uuid"),
			state = 1,
			mid = $(this).attr("mid");
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/assist_apply_audit_ajax",
			data:{"mid":mid,"status":status,"uuid":uuid,"state":state},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	$('.remove').on("click",function(){
		var status = -1,
			mid = $(this).attr("mid");
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/assist_apply_audit_ajax",
			data:{"mid":mid,"status":status},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	//文本域暂存
	$("textarea").blur(function(){
		var val = $(this).val();
			reg = new RegExp("\n", "g"),
    		str = val.replace(reg, "<br/>");
		$(this).next("input").val(str);
	})
	$('.true').click(function(){
		var mid = $(this).attr("mid"),
			status = parseInt($(this).attr('status'))+1;
		$('#customeModal').find('.modal-body').end().modal('show');
		$('#customeModal').find(".btn-affirm").attr({"mid":mid});
		$('#customeModal').find(".btn-affirm").attr({"status":status});
	})
	
	//提交
	$('.btn-affirm').click(function(){
		var tag = true;
		$("[name='confirm']").each(function(){
			var val = $(this).val();
			if(val==''){
				$(this).parent().find('.error-item').show();
				tag = false;
			}
		})
		if($("td").find("input:radio:checked").length==0){
			$('.radio-inline').parent().find(".error-item").show();
			tag = false;
		}
		if(tag){
			var mid = $(this).attr("mid"),
				status = $(this).attr("status"),
				confirm = $("[name='confirm_hid']").val(),
				confirm_proposal = $("[name='confirm_proposal_hid']").val(),
				confirm_evaluate = $('input:radio:checked').val(),
				modal = $("#customeModal");
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"mid":mid,"status":status,"confirm_message":confirm,"confirm_proposal":confirm_proposal,"confirm_evaluate":confirm_evaluate},
				url:"__APP__/Index/assist_apply_audit_ajax",
				success:function(data){
					success_pop(data.status);
				}
			});
		}
	})
	$("[name='confirm'],.radio-inline").click(function(){
		$(this).parent().find(".error-item").hide();
	})
	/*重新提交*/
	$(".btn-rest-submit").click(function(){
		var mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid");

		$("#myModal_submit .btn-affirm").attr("mid",mid);
		$("#myModal_submit .btn-affirm").attr("uuid",uuid);
		$(".submit_info").removeClass("red").val("");
		$('#myModal_submit').modal('toggle');
	});
	
	$("#myModal_submit .btn-affirm").click(function(){
		var mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid"),
			status = 1,
			state = 1,
			submit_info = $(".submit_info").val();

		if(submit_info==""||submit_info=="重新提交理由必填"){
			$(".submit_info").addClass("red").val("重新提交理由必填");
		}else{
			$('#myModal_submit').hide();
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				global: false,
				url:"__APP__/Index/assist_apply_audit_ajax",
				data:{"mid":mid,"status":status,"uuid":uuid,"state":state,"submit_info":submit_info},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});

	$(".submit_info").focus(function(){
		if($(this).val()=="重新提交理由必填"){
			$(this).removeClass("red").val("");
		}
	});
});
</script>
</body>
</html>